<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>添加任务</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/jquery-ui-1.8.18.custom.css" />
  <script type="text/javascript" src="js/jquery.js"></script>
  <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
    
  
</head>
<body>
	<%@ include file="include/topbar.jsp" %>
	<div class="container" style="margin-top: 60px;" >
			<div class="row">
			<jsp:include page="include/left.jsp" >
					<jsp:param value="goal" name="tag"/>
				</jsp:include>
	      <div class=" span9 ">
	      <ul class="breadcrumb" style="margin-bottom:0px;border-radius:3px 3px 0 0;margin-top:0px">		
				<li >
					<h4>添加任务</h4>
				</li>
		</ul>
    	<div class=" wall" style="border-radius:0 0 3px 3px;padding-left:200px">
          <div class="control-group">
            <label for="input01" class="control-label">任务名称</label>
            <div class="controls">
              <input type="text" id="input01" class="input-xlarge"/>
              
            </div>
          </div>
           <div class="controls">
            	<input type="hidden" name="leader" />
              <select id="select01">
              <option>请选择负责人</option>
              <c:set var="curname" value="${sessionScope.name}" />
              <c:forEach var="employee" items="${requestScope.emList}">
              	<c:if test="${employee.name ne curname}">
              	<option id="${employee.id}">${employee.name}</option>
              	</c:if>
              	</c:forEach>
	              </select>
	           		 </div>
          <div class="control-group">
            
          </div>
          
          <div class="control-group">
            <label for="input02" class="control-label">开始时间</label>
            <div class="controls">
            <input type="text" id="datepicker01" value="${task.beginTime}" />
            </div>
          </div>
          
		   <div class="control-group">
            <label for="select03" class="control-label">截止时间</label>
            <div class="controls">
             <input type="text" id="datepicker02" value="${task.beginTime}" />
            </div>
          </div>
		   <div class="control-group">
            <label for="select02" class="control-label">任务状态</label>
            <div class="controls">
              <select id="select02">
                <option>新任务</option>
                <option>进行中</option>
                <option>已完成</option>
              </select>
            </div>
          </div>
		   <div class="control-group">
            <label for="select03" class="control-label">任务级别</label>
            <div class="controls">
              <select id="select03">
                <option>重要不紧急</option>
                <option>紧急不重要</option>
                <option>紧急重要</option>
                <option>不紧急不重要</option>
              </select>
            </div>
          </div>
          
          
          <div class="control-group">
            <label for="textarea" class="control-label">任务描述</label>
            <div class="controls">
              <textarea rows="3" id="textarea" class="input-xlarge"></textarea>
            </div>
          </div>
          <div >
            <a class="btn btn-primary" id="addtask">确认操作</a>
            <a class="btn btn-danger" href="task.jspx?gid=${curgoal.id }">返回</a>
          </div>
        </div>
        </div>

</div></div>
<script type="text/javascript">

	$(document).ready(function() {
	
		$(function() {
			$("#datepicker01").datepicker({
				dateFormat: 'yy-mm-dd'
			});
		});
		
		$(function() {
			$("#datepicker02").datepicker({
				dateFormat: 'yy-mm-dd'
			});
		});
	
		$("#addtask").click(function() {
			var taskName = $("#input01").val();
			var empName = $("#select01").val();
			var empId = $("option:contains('"+ empName +"')").attr("id");
			var beginTime = $("#datepicker01").val();
			var endTime = $("#datepicker02").val();
			var state = $("#select02").val();
			var level = $("#select03").val();
			var desc = $("#textarea").val();
			
			
			
			if(taskName.trim() == "" || empName.trim() == "请选择负责人" || empId.trim() == "" || beginTime.trim() == "" || endTime.trim() == "" || state.trim() == "" || level.trim() == "" || desc.trim() == "") {
				alert("不能为空");
			} else {
				$.ajax({
					url : "addtask.jspx",
					type : "POST",
					data : {
						taskName : taskName,
						empId : empId,
						beginTime : beginTime,
						endTime : endTime,
						state : state,
						level : level,
						desc : desc
					}
				}).done(function(msg) {
					if(msg == 1) {
						alert("添加成功");
					} else {
						alert("添加失败");
					}
				});
			}
		});
	});
</script>
</body>
</html>
